package br.ueg.ezrides.control;

import java.util.HashMap;

import br.com.vexillum.control.GenericControl;
import br.com.vexillum.util.Return;
import br.ueg.ezrides.control.validator.UserValidator;
import br.ueg.ezrides.modelo.entidades.Usuario;

public class UsuarioController extends GenericControl<Usuario> {

	public UsuarioController(HashMap<String, Object> data) {
		super(data);
	}

	public Return updatePassword(){
		Return ret = new Return(true);
		UserValidator validator = new UserValidator(entity, "updatePassword");
		ret.concat(validator.validateUpdatePassword((String)data.get("fldSenhaAtual"), (String)data.get("fldNovaSenha"), (String)data.get("fldCNovaSenha")));
		if(ret.isValid()){
			entity.setSenha((String)data.get("fldNovaSenha"));
			ret.concat(save());
		}
		return ret;
	}
}
